package homework;

import org.junit.Test;

import java.util.Arrays;

public class Selectsort02 {
    @Test
    public void test02(){
        int [] arr={10,99,66,45,35,68};
        selectsort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public void selectsort(int[] arr){
        for(int i=0;i<arr.length;i++){
            int index=i;
            for(int j=i+1;j<arr.length;j++){
                if (arr[j]<arr[index]){
                    index=j;
                }
            }
            swap(arr,i,index);

        }

        }
    public void swap(int[] arr,int i,int j){
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
    }

